package com.fish.passport.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fish.common.constant.QueryPage;
import com.fish.common.dao.BaseIbatisDao;
import com.fish.passport.po.PassProvider;
import com.fish.product.po.PerformTarget;
import com.fish.sight.po.Sight;

/**
 * @author clj
 */
@SuppressWarnings("unchecked")
public class PerformTargetDAO extends BaseIbatisDao {
	
	public int queryTargetCountByParams(String targetName) {
		Integer count=(Integer) super.getSqlMapClientTemplate().queryForObject(
				"PERFORM_TARGET.queryTargetCountByParams", targetName);
		return count;
	}
	
	/**
	 * 按条件查询
	 * 
	 * @param 查询参数
	 */
	public List<PerformTarget> queryTargetByParams(String targetName,int start,int pageSize) {
		Map<String, Object> params=new HashMap<String, Object>();
		params.put("targetName", targetName);
		params.put("start", start);
		params.put("pageSize", pageSize);
		return super.getSqlMapClientTemplate().queryForList(
				"PERFORM_TARGET.queryTargetByParams", params);
	}

	/**
	 * 新增
	 * 
	 * @param PassProvider对象
	 */
	public void addPerformTarget(PerformTarget performTarget) {
		super.getSqlMapClientTemplate().insert(
				"PERFORM_TARGET.insert", performTarget);
	}

	/**
	 * 修改
	 */
	public void updatePerformTarget(PerformTarget performTarget) {
		super.getSqlMapClientTemplate().update(
				"PERFORM_TARGET.updatePerformTarget", performTarget);
	}

	/**
	 * 删除
	 */
	public void deleteTargetById(String targetId) {
		super.getSqlMapClientTemplate().delete(
				"PERFORM_TARGET.deleteTargetById", targetId);
	}
	public PerformTarget getPerformTargetById(String targetId) {
		return (PerformTarget)super.getSqlMapClientTemplate().queryForObject(
				"PERFORM_TARGET.selectPerformTargetById", targetId);
	}
	
	public Long queryPerformTargetCountByObject(PerformTarget performTarget){
		return  (Long) this.getSqlMapClientTemplate().queryForObject("PERFORM_TARGET.countPerformTargetWithPaging", performTarget);
	}
	
	public  List<PerformTarget> queryPerformTargetyObject(PerformTarget performTarget,QueryPage queryPage){
		if (performTarget!=null&&queryPage!=null) {
			performTarget.setBeginItem(queryPage.getBeginItem());
			performTarget.setEndItem(queryPage.getPageSize());
		}		
		return (List<PerformTarget>) this.getSqlMapClientTemplate().queryForList("PERFORM_TARGET.selectPerformTargetWithPaging", performTarget);
	}
	
}
